<!-- 委外订单未收货报表 -->
<template>
  <div class="mod-config">
    <basic-container>
      <el-divider content-position="left">查询条件</el-divider>
      <el-form size="mini" label-width="80px">
        <el-form-item label="委外订单生成时间">
            <el-col :span="11">
                <el-date-picker type="date" placeholder="选择日期" v-model="dataForm.beginTime" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
            </el-col>
            <el-col class="line" :span="2" style="text-align: center;">至</el-col>
            <el-col :span="11">
                <el-date-picker type="date" placeholder="选择日期" v-model="dataForm.endTime" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
            </el-col>
        </el-form-item>
        <el-form-item label="销售部门" v-if="[1,21,23].includes(userInfo.lessDeptId)">
          <el-select v-model="dataForm.deptId" clearable>
            <el-option v-for="item in deptOptions" :value="item.id" :label="item.name" :key="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="销售部门"  v-else>
          <el-select v-model="dataForm.deptId" disabled>
            <el-option v-for="item in deptOptions" :value="item.id" :label="item.name" :key="item.id"></el-option>
          </el-select>
        </el-form-item>

        <el-row style="margin-top: 10px;">
          <el-form-item label-width="5px">
            <el-link  :href="printUrl" target="_blank" type="primary"><el-button size="mini" type="primary" @click="getWorkParams">查 询</el-button></el-link>
          </el-form-item>
        </el-row>
      </el-form>
    </basic-container>
  </div>
</template>

<script>
  let params = ''
  import { filterParams } from '@/util/tools'
  import { getDateFormat } from '@/util/tools'
  import { mapGetters } from 'Vuex'
  import {getDeptInfo} from '@/api/admin/dept'
  import { getUserInfo} from '@/api/admin/user' //根据工号 获取用户信息

  export default {
      data () {
        return {
          printUrl: '',
          dataForm: {
              createUserName: '',
              createUser: '',
              brandName: '',
              beginTime: '',
              endTime: '',
              deptId: ''
          },
          deptOptions: []
        };
      },
      computed: {
        ...mapGetters(['userInfo','bizData'])
      },
      created() {
        this.dataForm.beginTime = getDateFormat(new Date())
        this.dataForm.endTime = getDateFormat(new Date())
        this.getDeptList();
      },
      methods:{
        getWorkParams() {
          params = '/consignNotReceive.cpt'
          let data = filterParams(this.dataForm)
          let parameter = ''
          for(let key in data){
            parameter += '&' + key + '=' + this.dataForm[key]
          }
          this.printUrl = this.bizData.printUrl + params + parameter
        },
        //  获取部门列表
        getDeptList() {
          getDeptInfo().then(result => {
            this.deptOptions = result.data.data
          })
        }
      }
    }
</script>

<style lang="scss" scoped>
  .row-bg {
    background-color: #cadee8;
    // padding-left: 15px;
    padding-right: 15px;
    padding-top: 5px;
    margin-bottom: 2px;
  }
</style>
